home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE6 / PD / PDF / GuiLib / Task / h / GuiRegister < prev    next >
Text File  |  2003-02-14  |  6KB  |  172 lines

  1. //--------------------------------------------------------------------------
  2. //
  3. //   Copyright (c) 2002, Colin Granville
  4. //
  5. //   All rights reserved.
  6. //
  7. //   Redistribution and use in source and binary forms, with or
  8. //   without modification, are permitted provided that the following 
  9. //   conditions are met:
  10. //
  11. //      * Redistributions of source code must retain the above copyright 
  12. //        notice, this list of conditions and the following disclaimer.
  13. //
  14. //      * Redistributions in binary form must reproduce the above 
  15. //        copyright notice, this list of conditions and the following 
  16. //        disclaimer in the documentation and/or other materials 
  17. //        provided with the distribution.
  18. //
  19. //      * The name Colin Granville may not be used to endorse or promote 
  20. //        products derived from this software without specific prior 
  21. //        written permission.
  22. //
  23. //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  24. //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  25. //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  26. //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  27. //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  28. //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  29. //   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  30. //   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  31. //   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  32. //   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  33. //   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
  34. //   OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //--------------------------------------------------------------------------
  37.  
  38. #ifndef GuiRegister_h
  39. #define GuiRegister_h
  40.  
  41. #include "GuiObject.h"
  42.  
  43.  
  44. enum Claim {DONT_CLAIM,CLAIM};
  45.  
  46. //*************************************************************************************
  47.  
  48. class GuiEventTarget
  49. {
  50.   public: 
  51.     virtual ~GuiEventTarget();
  52. };
  53.  
  54. //*************************************************************************************
  55. class GuiNullEventRegisterItem;
  56.  
  57. class GuiNullEventTarget : public GuiEventTarget
  58.    public:
  59.      GuiNullEventTarget();
  60.      GuiNullEventTarget(unsigned int interval);
  61.      virtual ~GuiNullEventTarget();
  62.      virtual void execute()=0;
  63.  
  64.      void setInterval(unsigned int interval=0);
  65.      void destroy();
  66.  
  67.      operator const void*() const {return item;}
  68.      operator void*()             {return item;}
  69.      bool operator!() const       {return item==0;}
  70.  
  71.   private:
  72.      GuiNullEventRegisterItem* item;
  73.      friend class GuiNullEventRegisterItem;
  74.  
  75.      GuiNullEventTarget(const GuiNullEventTarget&); //copying not allowed - not defined;
  76.      GuiNullEventTarget& operator=(const GuiNullEventTarget&);
  77. };
  78.  
  79.  
  80. //*************************************************************************************
  81.  
  82. class GuiToolboxRegisterItem;
  83.  
  84. class GuiToolboxEventTarget : public GuiEventTarget
  85.    public:
  86.      GuiToolboxEventTarget();
  87.      GuiToolboxEventTarget(const GuiObject*,int event_code);
  88.      virtual ~GuiToolboxEventTarget();
  89.      virtual Claim execute(GuiToolboxEvent&,const GuiIdBlock&)=0;
  90.      void          setListener(const GuiObject*,int event_code);
  91.      void          destroy();
  92.  
  93.      operator const void*() const {return item;}
  94.      operator void*()             {return item;}
  95.      bool operator!() const       {return item==0;}
  96.  
  97.   private:
  98.      GuiToolboxRegisterItem* item;
  99.      friend class GuiToolboxRegisterItem;
  100.  
  101.      GuiToolboxEventTarget(const GuiToolboxEventTarget&); //copying not allowed - not defined;
  102.      GuiToolboxEventTarget& operator=(const GuiToolboxEventTarget&);
  103. };
  104.  
  105. //*************************************************************************************
  106.  
  107. class GuiWimpRegisterItem;
  108.  
  109. class GuiWimpEventTarget : public GuiEventTarget
  110.    public:
  111.      GuiWimpEventTarget();
  112.      GuiWimpEventTarget(const GuiObject*,int event_code);
  113.      virtual ~GuiWimpEventTarget();
  114.      virtual Claim execute(GuiWimpPollBlock&,const GuiIdBlock&)=0;
  115.      void          setListener(const GuiObject*,int event_code);
  116.      void          destroy();
  117.  
  118.      operator const void*() const {return item;}
  119.      operator void*()             {return item;}
  120.      bool operator!() const       {return item==0;}
  121.  
  122.   private:
  123.      GuiWimpRegisterItem* item;
  124.      friend class GuiWimpRegisterItem;
  125.  
  126.      GuiWimpEventTarget(const GuiWimpEventTarget&); //copying not allowed - not defined;
  127.      GuiWimpEventTarget& operator=(const GuiWimpEventTarget&);
  128. };
  129.  
  130.  
  131. //*************************************************************************************
  132.  
  133. class GuiMessageRegisterItem;
  134.  
  135. class GuiMessageEventTarget : public GuiEventTarget
  136.    public:
  137.      GuiMessageEventTarget();
  138.      GuiMessageEventTarget(int message_code);
  139.      virtual ~GuiMessageEventTarget();
  140.      virtual Claim execute(GuiWimpMessage&) = 0;
  141.      void setListener(int message_code);
  142.      void destroy();
  143.  
  144.      operator const void*() const {return item;}
  145.      operator void*()             {return item;}
  146.      bool operator!() const       {return item==0;}
  147.  
  148.   private:
  149.      GuiMessageRegisterItem* item;
  150.      friend class GuiMessageRegisterItem;
  151.  
  152.      GuiMessageEventTarget(const GuiMessageEventTarget&); //copying not allowed - not defined;
  153.      GuiMessageEventTarget& operator=(const GuiMessageEventTarget&);
  154. };
  155.  
  156. //*************************************************************************************
  157.  
  158. struct GuiRegister
  159. {
  160.     static void          initialise(GuiIdBlock& id_block);
  161.     static void          poll(int *event_code=0, GuiWimpPollBlock* poll_block=0, int* poll_word=0);
  162.     static unsigned int  get_null_event_time();
  163.   private:
  164.     static void          dispatch(int event_code,GuiWimpPollBlock&);
  165. }; 
  166.  
  167. #endif
  168.